Keep template argument facts of catch and finally blocks - #6608
Merged
ondrejmirtes merged 2 commits intoSep 27, 2026
Merged
Conversation
A catch block that ends by throwing or returning is left out of the scope after the try-catch, and the finally block reaches it only through processFinallyScope(), which carries variable state. The facts the observation pass collected in them - a new Collection([1]) sent to Collection<int> - were lost with the scopes, the site stayed unresolved and the second pass reported Collection<unresolved(1)>. The constraints of every block are now joined into the scope after the try-catch. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VpbB99tJfUmeArX74xqvHv
ondrejmirtes
force-pushed
the
template-argument-facts-in-terminating-branches
branch
from
September 27, 2026 01:16
8b1be1f to
3c01737
Compare
ondrejmirtes
deleted the
template-argument-facts-in-terminating-branches
branch
September 27, 2026 01:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
unresolvedTemplateArguments(bleeding edge), a template argument site inside acatchblock that ends by throwing or returning, or inside afinallyblock, was never resolved:TryCatchHandlerleaves an always-terminating catch block out of the scope after the try-catch, and the finally block reaches it only throughprocessFinallyScope(), which carries variable state. The facts the observation pass collected in those blocks were dropped with their scopes. The constraints of every block (try, each catch, finally) are now joined into the scope after the try-catch - constraints are a persistent collection deduplicated by node identity, so joining a shared prefix again costs nothing.Found on Slevomat through the closure signature inference in #6604, which inherits the same observation pass.
tests/PHPStan/Analyser/nsrt/template-argument-try-catch.phpfails without the fix (Collection<unresolved(1)>for the throwing catch and the finally block).TryCatchHandler.cpp), side-by-side / smoke green, expected version bumped.🤖 Generated with Claude Code
https://claude.ai/code/session_01VpbB99tJfUmeArX74xqvHv